﻿import org.apache.commons.math3.analysis.interpolation.SplineInterpolator;  
import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;  

double[] x = new double[38];  
double[] y = new double[38];  
for (int i = 0; i < 38; i++) {  
    x[i] = -1047 + i * (264 + 1047) / 37.0;  
    y[i] = Math.cos(x[i]); // 示例函数  
}  

SplineInterpolator interpolator = new SplineInterpolator();  
PolynomialSplineFunction spline = interpolator.interpolate(x, y);  
double yNew = spline.value(10.0); // 插值点  